export function paramsStringHandler(params: any) {
  let paramsString = '?';
  for (const k in params) {
    paramsString += `${k}=${params[k]}&`;
  }
  return paramsString.substr(0, paramsString.length - 1);
}
console.log(process.env)
export let xlsxHost = '/app-admin'
if(process.env.NODE_ENV === "production"){
  xlsxHost = '/api'
}

export type exportType =
   'reviewList'
   | 'paperList'
   | 'tagList'

export const exportMap: Record<exportType, Function> = {
  reviewList: exportReviewList,
  paperList: exportPaperList,
  tagList:exportTagList,
};

const generateExportUrl = (baseUrl: string, params: any) => {
  return Promise.resolve(xlsxHost + baseUrl + paramsStringHandler(params));
};

export async function exportReviewList(params?: any) {
  return generateExportUrl('/teacher-admin/admin/teacher/game/review/exportReviewList', params);
}
export async function exportPaperList(params?: any) {
  return generateExportUrl('/teacher-admin/admin/v1/calculate/paper/question/downloadSgf', params);
}
export async function exportTagList(params?: any) {
  return generateExportUrl('/teacher-admin/admin/v1/calculate/paper/studentTag/exportList', params);
}


